package com.sig.formes;

public class Point {

	public float x,y = 0f;
	
	public static float minX = Float.MAX_VALUE;
	public static float minY = Float.MAX_VALUE;
	public static float maxX = Float.MIN_VALUE;
	public static float maxY = Float.MIN_VALUE;
	
	public static void testerMaxX(float x){
		if(x<Point.minX)
			Point.minX = x;
		if(x>Point.maxX)
			Point.maxX = x;
	}
	
	public static void testerMaxY(float y){
		if(y<Point.minY)
			Point.minY = y;
		if(y>Point.maxY)
			Point.maxY = y;
	}
	
	
	public static void testerMaxs(float x, float y){
		testerMaxX(x);
		testerMaxY(y);
	}
	
	
	public Point(){
	}
	public Point(float px,float py,boolean earcutting){
		x = px;
		y = py;
		
		if(!earcutting)
			testerMaxs(x, y);
	}
	public Point(float px,float py){
		this(px,py,false);
	}
	public float distanceTo(Point q) {
		Point p = this;
		float dx = p.x - q.x;
		float dy = p.y - q.y;
		return (float)Math.sqrt(dx*dx + dy*dy);
	}
	public String toString(){
		return "Point(x: "+x+" ; y: "+y+")";
	}
	
	public float getX() {
		return x;
	}
	
	public void setX(float x) {
		this.x = x;
		testerMaxX(x);
	}
	public float getY() {
		return y;
	}
	public void setY(float y) {
		this.y = y;
		testerMaxY(y);
	}
	
	
	public float getOpenGLX() {
		System.out.println("minX:"+minX+" maxX:"+maxX);
		System.out.println("minY:"+minY+" maxY"+maxY);
		
		
		
		float glx = (x-Point.minX)/(Point.maxX-Point.minX);
		System.err.println(glx);
		return glx;
	}
	public float getOpenGLY() {
		float gly = (y-Point.minY)/(Point.maxY-Point.minY);
		System.err.println(gly);
		return gly;
	}
	
}
